import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const baseUrl = CommonConfig.machinestatusUrl + '/v1/'
const upmsUrl = CommonConfig.upmsUrl + '/v1'

/**
 * 获取在线加工列表
 **/
export function getProcessingList (params) {
  const newUrl = baseUrl + 'online_processings'
  let query = {
    params
  }

  return axiosInstance.get(newUrl, query).then((res) => {
    return Promise.resolve((res))
  })
}
/**
 * 获取设备类型
 * dicGroupCode: machine_type
 * disable: true
 **/
export function getDeviceTypes () {
  let reqData = {
    params: {
      dicGroupCode: 'machine_type',
      disable: true
    }
  }
  const newUrl = upmsUrl + '/dict_by_gcode'
  return axiosInstance.get(newUrl, reqData).then((res) => {
    return Promise.resolve((res))
  })
}

/**
 * 获取在线加工详情
 * planningId 车间计划 ID
 * deviceId 设备 ID
 **/
export function getDetailed (id) {
  const url = `${baseUrl}online_processing/${id}/detailed`

  return axiosInstance.get(url).then(resp => {
    return Promise.resolve(resp)
  })
}
